package com.zpark.conrtoller;


import com.zpark.pojo.Empty;
import com.zpark.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/find_all_empty")
    public List<Empty> findAllEmpty(){
        return userService.findAllEmpty();
    }

    /**
     *  @RequestBody的作用，将请求参数以json格式接收
     */
    @RequestMapping("/add")
    public String addEmpty(Empty empty){
        userService.addEmpty(empty);
        return "添加用户成功";
    }

    @RequestMapping("ange")
    public String changeEmpty(Empty empty){
        userService.changeEmptyById(empty);
        return "修改用户成功";
    }

    // @PathVariable:获取url中的数据
    @RequestMapping("/del/{id}")
    public String removeEmpty(@PathVariable("id") Integer id){
        userService.removeEmptyById(id);
        return "删除用户成功";
    }
}
